const app = getApp()
Page({
  data: {
    avatar: '',
    nickName: ''
  },
  onLoad() {
    this.getUserProfile()
  },
  async getUserProfile() {
    const {
      code,
      data
    } = await wx.http.get('/userInfo')
    if (code !== 10000) return wx.utils.toast()
    this.setData({
      avatar: data.avatar,
      nickName: data.nickName
    })
    app.userProfile = {
      avatar: data.avatar,
      nickName: data.nickName
    }
  }
})